<template>
  <div class="blogProject-details-container">
    <Header></Header>
    <div class="blogProject-details-container-content">
      <div class="blogProject-details-container-content-left">
        <div class="card info-card">
          <div class="card-title"><span>基本信息</span></div>
          <el-descriptions :column="1" border>
            <el-descriptions-item label="毕设标题">
              <span>{{ blogProject.title }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="作者昵称">
              <span>{{ blogProject.nickName }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="作者QQ">
              <span>{{ blogProject.qq }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="作者微信">
              <span>{{ blogProject.wechat }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="源码价格">
              <span class="price-text">¥{{ blogProject.price }}</span>
              <el-tooltip class="item" effect="dark" content="该价格只包括项目的源代码，购买源码请添加作者QQ或者微信" placement="top">
                <span class="el-icon-question"></span>
              </el-tooltip>
            </el-descriptions-item>
            <el-descriptions-item label="浏览量">
              <span>{{ blogProject.viewsCount }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="发布时间">
              <span>{{ blogProject.createTime }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="在线地址">
              <el-link type="primary" :href="blogProject.projectUrl" target="_blank"
                :disabled="blogProject.projectUrl == null">点击在线预览</el-link>
            </el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="card support-card">
          <div class="card-title"><span>增值服务（非必选）</span></div>
          <el-descriptions :column="1" border>
            <el-descriptions-item label="支持二次开发/修改/定制" v-if="blogProject.isUpdate == 1">
              <el-tooltip class="item" effect="dark" content="具体服务请私聊作者" placement="top">
                <span class="el-icon-question"></span>
              </el-tooltip>
            </el-descriptions-item>
            <el-descriptions-item label="支持远程部署/安装/调试" v-if="blogProject.isDeploy == 1">
              <el-tooltip class="item" effect="dark" content="具体服务请私聊作者" placement="top">
                <span class="el-icon-question"></span>
              </el-tooltip>
            </el-descriptions-item>
            <el-descriptions-item label="支持1v1会议辅导" v-if="blogProject.isTeach == 1">
              <el-tooltip class="item" effect="dark" content="具体服务请私聊作者" placement="top">
                <span class="el-icon-question"></span>
              </el-tooltip>
            </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>

      <div class="blogProject-details-container-content-right">
        <div class="top-info-card">
          <el-image src="http://1.14.68.127:8160/api/oss/download/469976061405429760" fit="cover"
            class="top-info-card-image">
            <template #error>
              <div class="image-error">
                <span>封面加载失败</span>
              </div>
            </template>
          </el-image>
          <div class="top-info-card-content">
            <h1 class="top-info-card-title">{{ blogProject.title }}</h1>
          </div>
        </div>

        <div class="card video-card">
          <div class="video-container">
            <iframe :src="blogProject.videoUrl" scrolling="no" border="0" frameborder="no" framespacing="0"
              allowfullscreen="true"></iframe>
          </div>
        </div>

        <div class="card">
          <div class="card-title"><span>毕设介绍</span></div>
          <div class="ck-content" v-html="blogProject.htmlContent" v-highlight></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from '../components/header/index.vue';
import { getFrontProject } from '@/api/blog/blogProject';

export default {
  name: 'blog-blogProject-details',
  components: {
    Header,
  },
  data() {
    return {
      blogProject: {},
    };
  },
  mounted() {
    this.getProjectDetails();
  },
  methods: {
    getProjectDetails() {
      getFrontProject(this.$route.params.projectId).then((res) => {
        this.blogProject = res.data;
      });
    }
  }
}
</script>

<style scoped>
.blogProject-details-container {
  min-height: 100vh;
  background-color: #f5f7fa;
  padding-bottom: 40px;
}

.blogProject-details-container-content {
  display: flex;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

.blogProject-details-container-content-left {
  width: 30%;
  min-width: 300px;
}

.blogProject-details-container-content-right {
  width: 68%;
  flex-grow: 1;
}

/* 卡片通用样式 */
.card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 20px;
}


.card-title {
  border-left: 4px solid #409EFF;
  padding-left: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #333;
}

/* 顶部信息卡片 */
.top-info-card {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.top-info-card-image {
  width: 100%;
  height: 350px;
  filter: brightness(0.7);
  transition: all 0.3s;
}

.top-info-card-image:hover {
  filter: brightness(0.8);
}

.top-info-card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  color: white;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

.top-info-card-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.top-info-card-desc {
  font-size: 16px;
  opacity: 0.9;
}

/* 视频卡片 */
.video-card {
  padding: 0;
  overflow: hidden;
}

.video-card .card-title {
  padding: 20px 20px 10px;
}

.video-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 基本信息卡片 */
:deep(.el-descriptions) {
  margin-bottom: 20px;
}

:deep(.el-descriptions__body) {
  background-color: transparent;
}

.price-text {
  color: #f56c6c;
  font-weight: bold;
  font-size: 16px;
}

.view-icon {
  margin-left: 5px;
  color: #909399;
}

.action-buttons {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.full-width-btn {
  width: 100%;
}

/* 毕设介绍 */
.blogProject-intro h3 {
  margin: 20px 0 10px;
  color: #333;
  font-size: 16px;
}

.blogProject-intro p {
  line-height: 1.6;
  color: #606266;
  margin-bottom: 15px;
}

/* 响应式设计 */
@media (max-width: 992px) {
  .blogProject-details-container-content {
    flex-direction: column;
    padding: 15px;
  }

  .blogProject-details-container-content-left,
  .blogProject-details-container-content-right {
    width: 100%;
  }

  .info-card {
    position: static;
  }

  .top-info-card-title {
    font-size: 24px;
  }
}

@media (max-width: 768px) {
  .top-info-card-image {
    height: 250px;
  }

  .top-info-card-content {
    padding: 20px;
  }
}

.image-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #909399;
  background-color: #f5f7fa;
}

.image-error .el-icon {
  font-size: 40px;
  margin-bottom: 10px;
}
</style>
